<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                <form id="search-form" role="form" class="form-horizontal">
                    <input type="hidden" readonly id="productMember" name="productMember" class="form-control" value="${user.userRealname}">
                    <div class="form-group">
                        <label class="control-label col-sm-1">海关编号:</label>
                        <div class="col-sm-2">
                            <input type="text" id="refusedNo" name="refusedNo"   class="form-control">
                        </div>
                        <label class="control-label col-sm-1">柜号:</label>
                        <div class="col-sm-2">
                            <input type="text" id="refusedPlanNo" name="refusedPlanNo"   class="form-control">
                        </div>
                        <label class="control-label col-sm-1">状态:</label>
                        <div class="col-sm-2">
                            <select id="flag" name="flag"  class="form-control">
                                <option value="">请选择</option>
                                <option value="0">未退税</option>
                                <option value="1">已退税</option>
                            </select>
                        </div>

                        <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                    </div>
                </form>
            </div>
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <button  class="add-btn layui-btn  layui-btn-sm layui-btn-normal" style="margin-left: -2px">
                    <i class="fa fa-plus" aria-hidden="true"></i> 新增退税信息
                </button>
                <button  class="export-btn layui-btn  layui-btn-sm" style="margin-left: -2px">
                    <i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
                </button>
                <button  class="detail-btn layui-btn  layui-btn-sm layui-btn-warm" style="margin-left: -2px">
                    <i class="fa fa-search" aria-hidden="true"></i> 查看退税数据
                </button>

            </div>
            <!-- START 数据表格 -->
            <table id="relatedTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-page-size="15"
                   data-url="/sea/physical/refusedTax/findByCnd.do"
                   class="table table-striped table-hover">
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>



<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,layui,upload'}){}%>
<script>


    var $relatedTable = $('#relatedTable'),selections=[];
    $(function(){

        //指定允许上传的文件类型
        //START 表格配置
        $relatedTable.bootstrapTable({
            columns: [
                {
                    title: '海关编号',
                    field: 'refusedNo',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '柜号',
                    field: 'refusedPlanNo',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '渠道',
                    field: 'refusedChannel',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '实际报关金额',
                    field: 'refusedCreateMoney',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '实际清关金额',
                    field: 'refusedCustomMoney',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '报关单附件',
                    field: 'refusedOrderFile',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(null != v && v!='') {
                            var result = '<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result += '<i class="fa fa-download" aria-hidden="true"></i> <a href="' + v + '" download style="color: white">下载附件</a>';
                            result += '</button>';
                            return result;
                        }else{
                            return '暂无';
                        }
                    }
                },
                {
                    title: '清关附件',
                    field: 'refusedMoneyFile',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(null != v && v!='') {
                            var result = '<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result += '<i class="fa fa-download" aria-hidden="true"></i> <a href="' + v + '" download style="color: white">下载附件</a>';
                            result += '</button>';
                            return result;
                        }else{
                            return '暂无';
                        }
                    }
                },
                {
                    title: '发票附件',
                    field: 'refusedBillFile',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(null != v && v!='') {
                            var result = '<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result += '<i class="fa fa-download" aria-hidden="true"></i> <a href="' + v + '" download style="color: white">下载附件</a>';
                            result += '</button>';
                            return result;
                        }else{
                            return '暂无';
                        }
                    }
                },
                {
                    title: '退税凭证',
                    field: 'refusedFile',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(null != v && v!='') {
                            var result = '<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result += '<i class="fa fa-download" aria-hidden="true"></i> <a href="' + v + '" download style="color: white">下载附件</a>';
                            result += '</button>';
                            return result;
                        }else{
                            return '暂无';
                        }
                    }
                },
                {
                    title: '退税金额',
                    field: 'refusedMoney',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '状态',
                    field: 'flag',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(v==0){
                            return '未退税'
                        }else{
                            return '已退税'
                        }
                    }
                },
                {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
                $('.edit-btn').on('click',function(){//新增
                    var id=$(this).attr('data-val');
                    layer.open({
                        title: false,
                        closeBtn: 0,
                        type: 2,
                        area: ['100%','100%'],
                        skin: 'layer-ext-espresso',
                        content: ['/sea/physical/refusedTax/editPage.do?id='+id, 'yes']
                    });
                });

                //删除
                $('.del-btn').on('click',function(){
                    var delid = $(this).attr('data-val');
                    layer.confirm('确定要删除当前？', {
                        btn: ['确定','取消'],title:'提示'
                    }, function(){
                        var index = layer.load();
                        $.post('/sea/physical/refusedTax/delete.do',{id: delid},function(data){
                            if( data.ok ){
                                layer.close(index);
                                layer.msg(data.msg,{icon: 1,time: 1500},function(){
                                    //刷新页面
                                    $relatedTable.bootstrapTable('refresh');
                                });
                            }else{
                                layer.msg(data.msg,{icon: 0,time: 1500});
                                layer.close(index);
                            }
                        });
                    });
                });
            }
        });
    });


    // 操作菜单
    function optFormatter(value,row){
        var content='';
        content += '<button class="edit-btn btn btn-xs btn-info" data-val="' + row.id + '" title="修改"><i class="fa fa-edit"></i> 修改 </button>';
        if(row.refusedStatus==0) {
            content += '&nbsp;<button class="del-btn btn btn-xs btn-danger" data-val="' + row.id + '" title="删除"><i class="fa fa-trash-o"></i> 删除</button>';
        }
        return content;
    }



    $('.search-btn').on('click',function(){
        $relatedTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/physical/refusedTax/findByCnd.do?'+$('#search-form').serialize() });
    });

    //新增
    $('.add-btn').on('click',function(){//新增
        layer.open({
            title: false,
            closeBtn: 0,
            type: 2,
            area: ['100%','100%'],
            skin: 'layer-ext-espresso',
            content: ['/sea/physical/refusedTax/addPage.do', 'yes']
        });
    });

    $('.detail-btn').on('click',function(){
        layer.open({
            type: 2,
            scrollbar: false,
            area: ['800px','600px'],
            content: ['/sea/physical/refusedTax/detail.do', 'no']
        });
    });

    $(".export-btn").click(function () {
        window.location.href='/sea/physical/refusedTax/export?'+$('#search-form').serialize();
    });
</script>
</body>
</html>
